package com.xmut.rc;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @description: 服务启动类
 * @author: XS
 * @date: 2022/5/23
 */
@Slf4j
@SpringBootApplication
@MapperScan({"com.xmut.rc.mapper"})
@ComponentScan("com.xmut")
@EnableTransactionManagement
public class RCApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(RCApplication.class, args);

        //环境
        Environment env = application.getEnvironment();
        //本地ip
        String ip = InetAddress.getLocalHost().getHostAddress();
        //端口
        String port = env.getProperty("server.port");
        //启动信息
        log.info("\n----------------------------------------------------------\n\t" +
                "Account-Manage-System is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + "/\n\t" +
                "External: \thttp://" + ip + ":" + port + "/\n\t" +
                "Knife4j文档: \thttp://" + ip + ":" + port + "/doc.html\n" +
                "----------------------------------------------------------");
    }

}
